- name: d8.flant-pricing.grafana-agent
  rules:

  - alert: FlantPricingSucceededSamplesMetricIsAbsent
    expr: |
      absent(prometheus_remote_storage_queue_highest_sent_timestamp_seconds{job="pricing"}) == 1
    for: 30m
    labels:
      severity_level: "6"
      tier: cluster
      d8_module: flant-integration
      d8_component: pricing
    annotations:
      plk_protocol_version: "1"
      plk_markup_format: "markdown"
      plk_create_group_if_not_exists__d8_flant_pricing_malfunctioning: "FlantPricingMalfunctioning,tier=cluster,prometheus=deckhouse,kubernetes=~kubernetes"
      plk_grouped_by__d8_flant_pricing_malfunctioning: "FlantPricingMalfunctioning,tier=cluster,prometheus=deckhouse,kubernetes=~kubernetes"
      description: |
        There are no succeeded samples metric from the Grafana Agent.

        To get more details:

        Check pods state: `kubectl -n d8-flant-integration get pod -l app=pricing`
        or logs: `kubectl -n d8-flant-integration logs -l app=pricing -c grafana-agent`
      summary: Crucial metrics are missing.

  - alert: FlantPricingNotSendingSamples
    expr: |
      sum(increase(prometheus_remote_storage_queue_highest_sent_timestamp_seconds{job="pricing"}[10m])) == 0
    for: 30m
    labels:
      severity_level: "6"
      tier: cluster
      d8_module: flant-integration
      d8_component: pricing
    annotations:
      plk_protocol_version: "1"
      plk_markup_format: "markdown"
      plk_create_group_if_not_exists__d8_flant_pricing_malfunctioning: "FlantPricingMalfunctioning,tier=cluster,prometheus=deckhouse,kubernetes=~kubernetes"
      plk_grouped_by__d8_flant_pricing_malfunctioning: "FlantPricingMalfunctioning,tier=cluster,prometheus=deckhouse,kubernetes=~kubernetes"
      description: |
        Succeeded samples metric of the Grafana Agent is not increasing.

        To get more details, check logs of the following containers:
        - `kubectl -n d8-flant-integration logs -l app=pricing -c grafana-agent`
        - `kubectl -n d8-flant-integration logs -l app=pricing -c pricing`
      summary: Flant-pricing cluster metrics are not being delivered
